package cn.zhentao.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.zhentao.pojo.TCarImage;
import cn.zhentao.service.TCarImageService;

@RestController
@RequestMapping("carImage")
public class CarImageController {

    @Autowired
    private TCarImageService tCarImageService;
    
    
        
        /**查询所有*/
        @RequestMapping("findList")
        public List<TCarImage> findList(){
           return tCarImageService.list(); 
            
        }
    
    
    
    
    
        /**
         * 添加
         * @param carImage 信息
         * @return 添加结果
         */
    
        @PostMapping("add")
        public String add(@RequestBody TCarImage carImage) {
            boolean save = tCarImageService.save(carImage);
            return save ? "添加成功" : "添加失败";
        }
    
    
    
        /**
         * 修改
        * @param carImage 信息
         * @return 修改结果
         */
        @PostMapping("update")
        public String update(@RequestBody TCarImage carImage) {
            boolean update = tCarImageService.updateById(carImage);
            return update ? "修改成功" : "修改失败";
        }
    
    
        /**
         * 根据ID查询
         * @param id ID
         * @return 信息
         */
        @GetMapping("findById")
        public TCarImage findById(@RequestParam Integer id) {
            return tCarImageService.getById(id);
        }
    
        /**
         * 删除
         * @param id ID
         * @return 删除结果
         */
        @GetMapping("delete")
        public String delete(@RequestParam Integer id) {
            boolean delete = tCarImageService.removeById(id);
            return delete ? "删除成功" : "删除失败";
        }
}
